import { createStore } from 'vuex'

import cart from './modules/cart'
import user from './modules/user'
import category from './modules/category'
import createPersistedstate from 'vuex-persistedstate'

// import Cookies from 'js-cookie'
export default createStore({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    user,
    cart,
    category
  },
  plugins: [
    createPersistedstate({
      // localStorage转cookie的方法
      // storage: {
      //   getItem: key => Cookies.get(key),
      //   setItem: (key, value) => Cookies.set(key, value, { expires: 7 }),
      //   removeItem: key => Cookies.remove(key)
      // },
      key: 'erabbit-client-pc-store',
      paths: ['user', 'cart']
    })
  ]
})
